package org.agile2soft.nexoma.entity;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "USER_REQUESTS")
@SuppressWarnings({"serial"})
public class UserRequest implements java.io.Serializable {

    private UserRequestId id;
    private User user;
    private Request request;
    private boolean representative;

    public UserRequest() {
    }

    public UserRequest(UserRequestId id,
            User user, Request request,
            boolean representative) {
        this.id = id;
        this.user = user;
        this.request = request;
        this.representative = representative;
    }

    @EmbeddedId
    @AttributeOverrides( {
            @AttributeOverride(name = "documentNumber"
                              , column = @Column(name = "CIU_DOCUMENT_NUMBER", nullable = false, length = 25)),
            @AttributeOverride(name = "requestId", column = @Column(name = "SOL_ID", nullable = false)) })
    public UserRequestId getId() {
        return this.id;
    }

    public void setId(UserRequestId id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CIU_DOCUMENT_NUMBER", nullable = false, insertable = false, updatable = false)
    public User getUser() {
        return this.user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SOL_ID", nullable = false, insertable = false, updatable = false)
    public Request getRequest() {
        return this.request;
    }

    public void setRequest(Request request) {
        this.request = request;
    }

    @Column(name = "SOC_REPRESENTATIVE", nullable = false)
    public boolean isRepresentative() {
        return this.representative;
    }

    public void setRepresentative(boolean representative) {
        this.representative = representative;
    }

}
